cmake_minimum_required(VERSION 3.20)

# 项目名称
project(
  SGSim
  LANGUAGES C CXX
  VERSION 0.6.14
  DESCRIPTION "Simulation of Structural Mechanics"
  )

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  # 编译参数
  set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall")
else()
  message(WARNING "Unsupported ${CMAKE_CXX_COMPILER_ID} compiler !!!")
endif()


# 设置全局属性
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

# set(CMAKE_SKIP_INSTALL_RPATH TRUE)

set(Boost_USE_STATIC_LIBS OFF)  # 使用boost动态库
set(Boost_USE_DEBUG_LIBS OFF)  # 用于指定是否在Debug构建中使用Boost的Debug版本库
set(Boost_USE_DEBUG_RUNTIME OFF) # 变量用于指定是否在Debug构建中使用Debug版本的C++运行时库
set(Boost_USE_RELEASE_LIBS ON) # 控制是否使用Release版本的Boost库

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# 引入宏与函数
include(${CMAKE_SOURCE_DIR}/Resource/cmake/Tools.cmake)
include(${CMAKE_SOURCE_DIR}/Resource/cmake/PackageImport.cmake)
include(${CMAKE_SOURCE_DIR}/Resource/cmake/SGConfig.cmake)
include(${CMAKE_SOURCE_DIR}/Resource/cmake/DoxygenOptions.cmake)
include(${CMAKE_SOURCE_DIR}/Resource/cmake/CPackOptions.cmake)
include(${CMAKE_SOURCE_DIR}/Resource/cmake/InitializeBuildOptions.cmake)

# 检查版本号并更新程序版本文件
CHECK_VERSION()
# the build options
InitializeBuildOptions()

# 设置头文件查找目录
include_directories(${CMAKE_SOURCE_DIR}  
 ${CMAKE_BINARY_DIR}
 ${CMAKE_BINARY_DIR}/Utility/Algebra
 ${CMAKE_SOURCE_DIR}/Utility/Algebra
 ${CMAKE_INSTALL_PREFIX}/include/Utility/Algebra
 ${CMAKE_INSTALL_PREFIX}/include )

# 设置链接库查找目录
link_directories(${CMAKE_INSTALL_PREFIX}/lib)

# # 工具包
add_subdir(Utility)
# 数据结构
add_subdir(DataStructure)
# 数据管理
if(SG_BUILD_DBManager)
  add_subdir(DBManager)
endif()
# 数据导入
add_subdir(Import)
# 结果导出
add_subdir(Export)

add_subdir(SGFem)

# 安装NOTICES与LICENSE文件
install(FILES ${CMAKE_SOURCE_DIR}/NOTICES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION share/doc)
